package com.example.Service.Impl;

import com.example.Dao.CateGoryMapper;
import com.example.Service.CateGoryService;
import com.example.pojo.CateCory;
import com.example.pojo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.GetMapping;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class CateGoryServiceImpl implements CateGoryService {

    @Autowired
    private CateGoryMapper cateGoryMapper;

    //添加文章分类
    @Override
    public void addcateGory(CateCory cateCory,int createId) {

        cateCory.setCreateTime(LocalDateTime.now());
        cateCory.setUpdataTime(LocalDateTime.now());
        cateCory.setCreateUser(createId);
        cateGoryMapper.add(cateCory);
    }

    @Override
    public List<CateCory> list(int createId) {
        List<CateCory> CateCoryList = cateGoryMapper.list(createId);

        return CateCoryList;
    }

    //根据id查询文章详情
    @Override
    public CateCory selectDetail(Integer id) {
        return cateGoryMapper.selectDetail(id);
    }

    //修改文章
    @Override
    public void updata(CateCory cateCory) {

         cateGoryMapper.updata(cateCory);
    }

    //删除文章
    @Override
    public void delete(Integer id) {
        cateGoryMapper.delete(id);

    }

    //根据创建者id查询分类文章
    @Override
    public List<CateCory> selectCateGoryByUserid(int createId) {
        return cateGoryMapper.LookC(createId);
    }


}
